// TypeScript file
module Fighter {

    /**
     * 游戏结束——郭启航
     */
    export class GameOverUI extends eui.Component {
        public Tips: eui.Label;
        constructor() {
            super();
            this.skinName = "resource/assets/PlaneE/GameOver.exml"
            this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddTostarg, this)
              if (!GameUtil.PlayerMessage.instance.onePerson) {
                this.sendMsg();
            }
        }
        public is_restart: boolean;

        public GameOver_BackPage: eui.Image
        public onAddTostarg() {
            this.Tips.visible = false;
            this.is_restart = false;
            this.GameOver_BackPage.addEventListener(egret.TouchEvent.TOUCH_TAP, this.Close, this);
        }
        /**页面跳转*/
        public Close(evt: egret.TouchEvent) {
            if (GameUtil.PlayerMessage.instance.onePerson == false && Fighter.OlUI.OlUI_solo.is_match == false) {

                this.GameOver_BackPage.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.Close, this);
            } 
            GameUtil.PlayerMessage.instance.isGameOver = true;
            GameUtil.PlayerMessage.instance.isBuyAroundPlane = false;
            GameUtil.PlayerMessage.instance.isBuyFollowPlane = false;
            this.is_restart = true;
        }
            /**向开放数据域通信 */
        private sendMsg() {
            let platform: any = window.platform;
            platform.openDataContext.postMessage({
                win: "0",
                lose:"1"
            });
        }
    }
}